
<section id="content">

    <div class="page page-fullwidth-layout">

        <div class="pageheader">

            <h2>部门业绩</h2>

            <div class="page-bar">

                <ul class="page-breadcrumb">
                    <li>
                        <a href="{:url('/admin')}"><i class="fa fa-home"></i> 起始页</a>
                    </li>
                    <li>
                        <a href="{:url($data.module_url)}">{$data.module_name}列表</a>
                    </li>
                </ul>

            </div>

        </div>

        <!-- page content -->
        <div class="pagecontent">

            <!-- row -->
            <div class="row">
                <!-- col -->
                <div class="col-md-12">




                    <!-- tile -->
                    <section class="tile">

                        <!-- tile header -->
                        <div class="tile-header dvd dvd-btm">
                            <h1 class="custom-font"><strong>{$data.module_name}</strong> 列表</h1>
                            <ul class="controls">
                                <li><a href="javascript:void(0)" id="export"><i class="fa fa-plus mr-5"></i> 导出</a></li>
                            </ul>
                        </div>
                        <!-- /tile header -->

                        <!-- tile body -->
                        <div class="tile-body">
                           <div class="alert alert-info" style="display:none;">显示一些提示信息</div>
                            <div id="role_select_box">
                                {if($is_admin == 1)}
                                <select name="group_select" style="display: inline-block;width:20%;" class="form-control">
                                    <option value="0">选择部门</option>
                                    {if($groups)}
                                    {foreach $groups as $key=>$v)}
                                    <option value="{$v['id']}">{$v['group_name']}</option>
                                    {/foreach}
                                    {/if}
                                </select>
                                {/if}
                                <select name="user_select" style="display: inline-block;width:20%;" class="form-control">
                                    <option value="0">选择会员</option>
                                    {if($users)}
                                    {foreach $users as $key=>$v)}
                                    <option value="{$v['id']}">{$v['username']}</option>
                                    {/foreach}
                                    {/if}
                                </select>
                                <button class="btn btn-primary sub_permission">查询</button>
                            </div>
                            <div id="container">{$list}</div>
                        </div>
                        <!-- /tile body -->

                    </section>
                    <!-- /tile -->

                </div>
                <!-- /col -->
            </div>
            <!-- /row -->




        </div>
        <!-- /page content -->
        <script type="text/javascript">
            $(function() {

                //选择部门触发选择会员
                $('select[name = group_select]').change(function(){
                    $('select[name=user_select ]').html('');
                    var group_id = $(this).val();
                    if(group_id > 0) {
                        $.ajax({
                            type:"POST",
                            url:"{:url('/admin/Chart/getUsersByGroupId')}",
                            data: {group_id:group_id},
                            dataType: 'json',
                            success:function(res){
                                if(res.code == 200){
                                    if(res.data.length > 0){
                                        var i;
                                        var str = '<option value="0">选择员工</option>';
                                        for(i=0;i<res.data.length;i++){
                                            str += '<option value="'+res.data[i].id+'">'+res.data[i].username+'</option>';
                                        }
                                        // alert(str);
                                        $('select[name=user_select ]').html(str);
                                    }else{
                                        $('select[name=user_select ]').html('<option value="0">选择员工</option>');
                                    }
                                }
                            }
                        });
                    }
                })

                //选择角色获取角色权限
                $('select[name = user_select]').change(function(){
                    var group_id = $('select[name=group_select]').val();
                    var user_id  = $(this).val();
                    var datas = 0;
                    if(user_id > 0) {
                        window.location.href="/admin/Chart/groupYj/"+group_id+'/'+user_id+'/'+datas;
                    }
                })

                $('select[name = group_select]').val('<?=$group_id?>');
                $('select[name = user_select]').val('<?=$user_id?>');

                $('#export').click(function(){
                    var group_id = $('select[name=group_select]').val();
                    var user_id  = $('select[name=user_select ]').val();
                    if(user_id > 0){
                        var datas = '<?php echo serialize($datalist); ?>';
                        window.location.href="/admin/Chart/groupYj/"+group_id+'/'+user_id+'/'+datas;
                    }else{
                        alert('请选择员工');return false;
                    }

                });

            })

        </script>
    </div>

</section>
<!--/ CONTENT -->

